import 'package:baixing/routers/application.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

//商品推荐
class Recommend extends StatelessWidget {
  final List recommendList;

  Recommend({this.recommendList});

  Widget _recommendItem() {
    return
      Container(
        height: ScreenUtil().setHeight(330),
        child: ListView.builder(
            itemCount: recommendList.length,
            scrollDirection: Axis.horizontal,
            itemBuilder: (context, index) {
              return InkWell(
                onTap: () {
                  Application.router.navigateTo(
                      context, "detail?id=${recommendList[index]["goodsId"]}");
                },
                child: Container(
                  width: ScreenUtil().setWidth(250),
                  decoration: BoxDecoration(
                    color: Colors.white,
                    border: Border(
                      left: BorderSide(color: Colors.grey[100], width: 0.5),
                    ),
                  ),
                  child: Column(
                    children: <Widget>[
                      Image.network(recommendList[index]["image"],
                          height: ScreenUtil().setHeight(200),
                          fit: BoxFit.cover),
                      Text("￥${recommendList[index]["mallPrice"]}"),
                      Text("￥${recommendList[index]["price"]}",
                          style: TextStyle(
                              decoration: TextDecoration.lineThrough)),
                    ],
                  ),
                ),
              );
            }),
      );
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      child: Column(
        children: <Widget>[
          Container(
            alignment: Alignment.topLeft,
            padding:
            EdgeInsets.only(left: 10.0, top: 3.0, right: 0.0, bottom: 3.0),
            child: Text(
              "商品推荐",
              style: TextStyle(color: Colors.pink),
            ),
            decoration: BoxDecoration(
                color: Colors.grey[100],
                border: Border(
                    bottom: BorderSide(
                      width: 0.5,
                    ))),
          ),
          _recommendItem(),
        ],
      ),
    );
  }
}
